#!/bin/sh

SCAN_FILES=src_resault.txt

scan_dir()
{
    for name in `ls $1`
    do
        if [ -d ${1}/${name} ]
        then 
            scan_dir "${1}/${name}"
        else
            if [ ${name##*.} = "c" -o ${name##*.} = "s" ]
            then
                echo '${CMAKE_CURRENT_SOURCE_DIR}/'"${1}/${name}" >> ${SCAN_FILES}
            fi
        fi
    done
}


if [ $# = 1 ]
then
    if [ -f ${SCAN_FILES} ]
    then
        echo "rm ${SCAN_FILES} (OK)?"
        read OK
        if [ ${OK} = "OK" ]
        then 
            rm ${SCAN_FILES}
        else
            exit 0
        fi
    fi
    cd ${1}
    scan_dir .
else
    echo "./scan_dir <dir>"
fi